<#assign attribute=getCategoryAttribute(category.id)/>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8" />
        <title>${(attribute.title)?has_content?then(attribute.title,category.name)!}</title>
		<meta name="keywords" content="${(attribute.keywords)!}"/>
		<meta name="description" content="${(attribute.description)!}"/>
        <@tools.includePlace path="/common/697054d4-2b69-4476-b4fe-868c61316959.html"/> <#-- header -->
    </head>
    <body class="d-flex flex-column">
        <main class="flex-shrink-0">
            <@tools.includePlace path="/common/0b31f69d-dc03-407b-95af-88be3db0289e.html"/> <#-- nav -->
            <!-- Blog preview section-->
            <section class="py-5">
                <div class="container px-5">
                    <h2 class="fw-bolder fs-5 mb-4">最新文章</h2>
					<@import path="/fragment/tools.ftl" namespace="t"/><#-- 工具 -->
					<@cms.contentList categoryId=category.id containChild=category.containChild pageIndex=pageIndex pageSize=category.pageSize>
                    <div class="row gx-5">
						<#list page.list as a>
							<@t.merge 'categoryIds' a.categoryId/>
							<@t.merge 'userIds' a.userId/>
						</#list>
						<@cms.category ids=t.categoryIds><#assign categoryMap=map/></@cms.category>
						<@sys.user ids=t.userIds><#assign userMap=map/></@sys.user>
						<#list page.list as a>
                        <div class="col-lg-4 mb-5">
                            <div class="card h-100 shadow border-0">
                                <#if a.cover?has_content><img class="card-img-top" src="${a.cover!}" alt="${a.title}"/></#if>
                                <div class="card-body p-4">
                                    <div class="badge bg-primary bg-gradient rounded-pill mb-2">${(categoryMap[a.categoryId?string].name)!}</div>
                                    <a class="text-decoration-none link-dark stretched-link" href="${a.url}"><div class="h5 card-title mb-3">${a.title}</div></a>
                                    <p class="card-text mb-0">${a.description!}</p>
                                </div>
                                <div class="card-footer p-4 pt-0 bg-transparent border-top-0">
                                    <div class="d-flex align-items-end justify-content-between">
                                        <div class="d-flex align-items-center">
                                            <img class="rounded-circle me-3 avatar" src="${(userMap[a.userId?string].cover)!(site.sitePath+'assets/images/avatar.png')}" alt="${(userMap[a.userId?string].nickname)!}" />
                                            <div class="small">
                                                <div class="fw-bold">${(userMap[a.userId?string].nickname)!}</div>
                                                <div class="text-muted">${a.publishDate?date} &middot; ${a.clicks} 阅读</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
						</#list>
                    </div>
					
                    <ul class="pagination">
						<#if category.url?contains('?')><#assign pageParameter="pageIndex"/></#if>
						<#assign
							start=1
							end=page.totalPage
						/>
						<#if (page.pageIndex-5) gt start>
							<#assign start=page.pageIndex-4/>
						</#if>
						<#if (page.pageIndex+5) lt end>
							<#assign end=page.pageIndex+4/>
						</#if>
						<li class="page-item"><a class="page-link" href="${getPage(category.url,page.prePage,pageParameter)}">上一页</a></li>
						<#if start gt 1>
							<li class="page-item"><a class="page-link" href="${category.url}">1</a></li>
							<li class="page-item"><span class="page-link" href="javascript:void(0)">...</span></li>
						</#if>
						<#list start..end as n>
							<li class="page-item<#if n=page.pageIndex> active</#if>"><a class="page-link" href="${getPage(category.url,n,pageParameter)}">${n}</a></li>
						</#list>
						<#if end lt page.totalPage>
							<li class="page-item"><span class="page-link" href="javascript:void(0)">...</span></li>
							<li class="page-item"><a class="page-link" href="${getPage(category.url,page.totalPage,pageParameter)}">${page.totalPage}</a></li>
						</#if>
						<li class="page-item"><a class="page-link" href="${getPage(category.url,page.nextPage,pageParameter)}">下一页</a></li>
					</ul>
					</@cms.contentList>
                </div>
            </section>
        </main>
		<script>
            var itemString="itemType=category&itemId=${category.id}";
			var templatePath='${.current_template_name?keep_after('/')}';
        </script>
        <@tools.includePlace path="/common/704bd033-154c-40f4-a8c5-2d36c092c3fd.html"/> <#-- footer -->
    </body>
</html>
